<template>
    <div>
        <div class="container">
            <div class="title">
                <span>{{ detail.title }}</span>
                <span>{{ detail.createTime }} {{ currentTime }}</span>
            </div>
            <div class="source-name">发布人：{{ detail.sourceName }}</div>
            <p class="content">{{ detail.msgDate }}</p>
        </div>
    </div>
</template>

<script>
import { MessageDetailApi, DidReadApi } from '@/request/api';

export default {
    data() {
        return {
            detail: {},
            currentTime: null,
        };
    },
    created() {
        let date = new Date();
        this.currentTime = `${date.getHours()}:${date.getMinutes()}`;
        MessageDetailApi({
            id: this.$route.params.id,
        }).then((res) => {
            this.detail = res.data;
            this.detail = res.data;
            if (this.detail.isReader) {
                DidReadApi({
                    id: this.$route.params.id,
                }).then(() => {
                    return;
                });
            }
        });
    },
};
</script>

<style lang="less" scoped>
.container {
    margin-top: 0.2rem;
    background-color: #fff;
    padding: 0.3rem;
    box-sizing: border-box;
    color: #333;
    .title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.16rem;
        span {
            &:first-child {
                font-size: 0.3rem;
                font-weight: bold;
            }
            &:last-child {
                color: #ccc;
            }
        }
    }
    .source-name {
        color: #999;
        margin-bottom: 0.44rem;
    }
    .content {
        width: 100%;
        color: #666;
        text-indent: 2em;
        line-height: 0.46rem;
    }
}
</style>
